guint force_scale_pixbuf : 1;
GdkPixbuf *rendered_pixbuf;
+ GtkStateFlags last_rendered_state;
cairo_surface_t *rendered_surface;
gint rendered_surface_width;
gint rendered_surface_height;
+ GtkStateFlags last_surface_state;
gint last_surface_scale;
};
self->priv->storage_type = GTK_IMAGE_EMPTY;
self->priv->icon_size = GTK_ICON_SIZE_INVALID;
+ self->priv->last_rendered_state = GTK_STATE_FLAG_NORMAL;
+ self->priv->last_surface_state = GTK_STATE_FLAG_NORMAL;
self->priv->last_surface_scale = 0;
self->priv->orig_pixbuf_scale = 1;
}
self->priv->storage_type = GTK_IMAGE_EMPTY;
self->priv->icon_size = GTK_ICON_SIZE_INVALID;
self->priv->pixel_size = -1;
+ self->priv->last_rendered_state = GTK_STATE_FLAG_NORMAL;
self->priv->orig_pixbuf_scale = 1;
}
return destination;
}
+static gboolean
+check_invalidate_pixbuf (GtkIconHelper *self,
+ GtkStyleContext *context)
+{
+ GtkStateFlags state;
+
+ state = gtk_style_context_get_state (context);
+
+ if ((self->priv->rendered_pixbuf != NULL) &&
+ (self->priv->last_rendered_state == state))
+ return FALSE;
+
+ self->priv->last_rendered_state = state;
+ g_clear_object (&self->priv->rendered_pixbuf);
+
+ return TRUE;
+}
+
static GtkIconLookupFlags
get_icon_lookup_flags (GtkIconHelper *self, GtkStyleContext *context)
{
GtkIconInfo *info;
GtkIconLookupFlags flags;
- if (self->priv->rendered_pixbuf)
+ if (!check_invalidate_pixbuf (self, context))
return;
icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context));
GtkStyleContext *context,
GtkIconSet *icon_set)
{
- if (self->priv->rendered_pixbuf)
+ if (!check_invalidate_pixbuf (self, context))
return;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gint width, height;
cairo_t *cr;
+
+ if (!check_invalidate_pixbuf (self, context))
+ return;
+
if (self->priv->rendered_pixbuf)
return;
gint width, height;
GdkPixbuf *stated;
+ if (!check_invalidate_pixbuf (self, context))
+ return;
+
if (self->priv->rendered_pixbuf)
return;
check_invalidate_surface (GtkIconHelper *self,
GtkStyleContext *context)
{
+ GtkStateFlags state;
int scale;
+ state = gtk_style_context_get_state (context);
scale = get_scale_factor (self, context);
if ((self->priv->rendered_surface != NULL) &&
+ (self->priv->last_surface_state == state) &&
(self->priv->last_surface_scale == scale))
return FALSE;
+ self->priv->last_surface_state = state;
self->priv->last_surface_scale = scale;
if (self->priv->rendered_surface)